let defaultLists = JSON.parse(localStorage.getItem( 'todos' )) || []
let nextTodoId = defaultLists.length

export const addTodo = (text) => ({
  type: 'ADD_TODO',
  id: nextTodoId++,
  text
})

export const setVisibilityFilter = (filter) => ({
  type: 'SET_VISIBILITY_FILTER',
  filter
})

export const toggleTodo = (id) => ({
  type: 'TOGGLE_TODO',
  id
})

export const edit = (id) => ({
  type: 'EDIT',
  id: id
})

export const closeEdit = (id) => ({
  type: 'CLOSE_EDIT',
  id: id
})

export const saveEdit = (id, text) => ({
  type: 'SAVE_EDIT',
  id: id,
  text: text
})

export const del = (id) => ({
  type: 'DEL',
  id: id
})